#include"process.h"
#include<unistd.h>
#include<string.h>

#define STYLE '='
const int NUM = 101;

void FlushProcess(double current,double total){
  char buffer[NUM];
  memset(buffer,0,sizeof(buffer));
  const char* lable="|/-\\";
  int len = strlen(lable);

  static int cnt = 0;

  int num = (int)(current*100/total);
  int i = 0; 
  for(; i<num; i++){
    buffer[i] = STYLE;
  }
  double rate = current/total;
  cnt%=len;
  printf("[%-100s][%.1lf%%][%c]\r",buffer,rate*100,lable[cnt]);
  cnt++;
  fflush(stdout);
}
